<?php
namespace App\Http\Controllers\Admin;

use App\Models\SettingContent;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;

class AdminPlateController extends BaseController
{
   /**
    * 
    * @return 首页显示
    */
    public function index()
    {   
        $result = SettingContent::orderBy('created_at','asc')->paginate(20);
        return view('admin.setting.plate.index')->with('result',$result);
    
    } 
    
    /**
     * 板块信息修改页面
     */
    public function edit($id)
    {
      $arr = SettingContent::find($id);
       return view('admin.setting.plate.edit')->with('result',$arr);
    }
    
    /**
     * 
     */
    public function save(Request $request)
    {
         $id = Input::get('id');
        if ($id > 0)
            $ads_position = SettingContent::find($id);
        else
            $ads_position = new SettingContent;
        /*处理表单POST来的数据*/
        
        foreach (array_except(Input::all(), ['_token','id']) as $key => $val) {
            $ads_position->$key = $val;
        }

        if ($ads_position->save()) {
            return redirect("admin/setting/datas/forum");
        } else {
            return Redirect::back()->withInput()->withErrors('保存失败!');
        }
        
    }
}



















